package part20;

import part20.annotation.UseCase;

import java.util.List;

/**
 * 自定义注解的使用，使用@interface声明类为一个注解类
 * 注解的字段使用方法进行定义，且可以设置默认值
 */
public class PasswordUtils {

    @UseCase(id = 47, description = "password must contain at least one number")
    public boolean validatePassword(String password) {
        return password.matches("\\w*\\d\\w*");
    }

    @UseCase(id = 48)
    public String encryptPassword(String password) {
        return new StringBuilder(password).reverse().toString();
    }

    @UseCase(id = 49, description = "New password can't equals previous used one")
    public boolean checkForNewPassword(List<String> prevPasswords, String password) {
        return !prevPasswords.contains(password);
    }
}
